home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 64-bit_x64 / Russian / cpsimage.cab / data / xps / XpsCoreProperties.elf < prev    next >
Text File  |  2009-04-23  |  4KB  |  116 lines

  1. #load "sys/XmlWriter.elf";
  2. #load "xps/Xps.elf";
  3. #load "xps/XpsPackagePart.elf";
  4.  
  5. CLASS XpsCoreProperties EXTENDS XpsPackagePart {
  6.    // Fields
  7.    LIST metadata;
  8.    LIST names;
  9.    LIST propertyMap;
  10.  
  11.    // Methods
  12.    METHOD setProperty (STRING name, STRING value) {
  13.       try {
  14.          this.init ();
  15.  
  16.          STRING classname = this.propertyMap.ref (name: name);
  17.          LIST   params    = (name: name, value: value);
  18.  
  19.          XpsProperty p = REFLECTION.findClass (name: classname
  20.                             ).newInstance (params: params
  21.                             );
  22.          this.metadata.insert (name: p.name, obj: p);
  23.  
  24.          if (this.names.search (name: name) == -1)
  25.             this.names.insert (obj: name, entry: this.names.length ());
  26.          }
  27.       catch {
  28.          print "Unknown property <" + name + ">";
  29.          }
  30.    }
  31.  
  32.    METHOD getProperty (STRING name)
  33.      RETURNS (STRING value) {
  34.       XpsProperty prop = this.metadata.ref (name: name);
  35.       value = prop.value;
  36.    }
  37.  
  38.    METHOD propertyNames ()
  39.      RETURNS (LIST names) {
  40.       names = this.names;
  41.    }
  42.  
  43.    METHOD write (XmlWriter writer) {
  44.       this.init ();
  45.  
  46.       writer.writeDocumentStart ();
  47.       writer.writeElementStart (localName: "coreProperties");
  48.       writer.writeAttributeString (prefix: "xmlns", localName: "dc",
  49.          text: Xps.DC_ELEMS_NAMESPACE);
  50.       writer.writeAttributeString (prefix: "xmlns", localName: "dcterms",
  51.          text: Xps.DC_TERMS_NAMESPACE);
  52.       writer.writeAttributeString (localName: "xmlns",
  53.          text: Xps.CORE_PROPS_NAMESPACE);
  54.       writer.writeAttributeString (prefix: "xmlns", localName: "xsi",
  55.          text: Xps.XSI_NAMESPACE);
  56.  
  57.       XpsProperty prop;
  58.       foreach (this.names: name) {
  59.          prop = this.metadata.ref (name: name);
  60.          prop.write (writer: writer);
  61.          }
  62.  
  63.       writer.writeElementEnd ();
  64.       writer.flush ();
  65.    }
  66.  
  67.    METHOD init () {
  68.       if (this.propertyMap.length () != 0)
  69.          return;
  70.  
  71.       this.propertyMap.insert (name: "title",    obj: "XpsStringProperty");
  72.       this.propertyMap.insert (name: "subject",  obj: "XpsStringProperty");
  73.       this.propertyMap.insert (name: "creator",  obj: "XpsStringProperty");
  74.       this.propertyMap.insert (name: "created",  obj: "XpsDateTimeProperty");
  75.       this.propertyMap.insert (name: "modified", obj: "XpsDateTimeProperty");
  76.       this.propertyMap.insert (name: "keywords", obj: "XpsGenericProperty");
  77.    }
  78. }
  79.  
  80. /*****************************************************************************/
  81. CLASS XpsProperty {
  82.    // Fields
  83.    STRING name;
  84.    STRING value;
  85.  
  86.    // Public Methods
  87.    METHOD write (XmlWriter writer) {
  88.    }
  89. }
  90.  
  91. CLASS XpsGenericProperty EXTENDS XpsProperty {
  92.    // Public Methods
  93.    METHOD write (XmlWriter writer) {
  94.       writer.writeElementString (localName: this.name, text: this.value);
  95.    }
  96. }
  97.  
  98. CLASS XpsStringProperty EXTENDS XpsProperty {
  99.    // Public Methods
  100.    METHOD write (XmlWriter writer) {
  101.       writer.writeElementString (prefix: "dc", localName: this.name,
  102.          text: this.value);
  103.    }
  104. }
  105.  
  106. CLASS XpsDateTimeProperty EXTENDS XpsProperty {
  107.    // Public Methods
  108.    METHOD write (XmlWriter writer) {
  109.       writer.writeElementStart (prefix: "dcterms", localName: this.name);
  110.       writer.writeAttributeString (prefix: "xsi", localName: "type",
  111.          text: "dcterms:W3CDTF");
  112.       writer.writeString (text: this.value);
  113.       writer.writeElementEnd ();
  114.    }
  115. }
  116.